/*
 * @Author: wfl
 * @LastEditors: wfl
 * @description:
 * @updateInfo: 本次更新内容：
 * @Date: 2021-03-18 16:36:09
 * @LastEditTime: 2021-04-29 12:04:38
 */
import { Bind, Body, Controller, Get, Param, Post, Req, UploadedFiles, UseInterceptors } from '@nestjs/common';
import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { UploadService } from '../services/upload.service';

@Controller('chunk')
export class UploadController {
    constructor(private readonly uploadService: UploadService) { }

    @Get('filechunk')
    getFileChunk(): string {
        return this.uploadService.getFileChunk()
    }

    @Get('readychunk/:chunk')
    async getReadyChunk(@Param('chunk') fileChunk: string): Promise<Object>{
        console.log(fileChunk);
        
        return await this.uploadService.getReadyChunk(fileChunk)
    }

    @Post('upload')
    @UseInterceptors(AnyFilesInterceptor())
    uploadChunk(@Body() body, @UploadedFiles() file) {
        return this.uploadService.uploadChunk(body, file)
    }

    @Post('merage')
    merageChuank(@Body('fileMd5') fileMd5) {
        console.log(fileMd5);
        
        return this.uploadService.merageChuank(fileMd5)
    }
}